<template>
    <div class="ipt">
        <input-title :title="title" :placeholder="placeholder" :required="required"></input-title>
        <input type="text" :data-font="$i18n.locale" v-model="value" :placeholder="placeholder" :disabled="disabled" />
    </div>
</template>

<script>
import inputTitle from './input-title.vue';
export default {
    props: {
        title: {
            type: String,
            default: ''
        },
        required: {
            type: Boolean,
            default: false
        },
        placeholder: {
            type: String,
            default: ''
        },
        disabled: {
            type: Boolean,
            default: false
        },
        history: {
            type: String,
            default: ''
        }
    },
    components: {
        inputTitle
    },

    data() {
        return {
            value: this.history
        }
    },
    watch: {
        value: {
            deep: true,
            handler(newVal, oldVal) {
                this.$emit('message', newVal);
            },
            immediate: true
        },
        history: {
            deep: true,
            handler(newVal, oldVal) {
                this.value = newVal;
                this.$emit('message', newVal);
            },
            immediate: true
        }
    }
}
</script>

<style lang="less" scoped>
.ipt {
    width: 100%;
    flex-shrink: 1;
    display: flex;
    flex-direction: column;
}

input {
    width: 100%;
    border: none;
    outline: none;
    height: 0.85rem;
    background: none;
    border-bottom: 0.03rem solid #C5C5CA;
}

input[data-font='zh'] {
    font-size: 0.53rem;
    font-family: 'IdeaFonts-DianHei-DEJ', 'IdeaFonts-DianHei';
    font-weight: normal;
    color: #68656C;
    line-height: 0.85rem;
}

input[data-font='en'] {
    font-size: 0.48rem;
    font-family: 'Helvetica';
    color: #68656C;
    line-height: 0.75rem;
}

input[data-font='zh']::placeholder {
    font-size: 0.53rem;
    font-family: 'IdeaFonts-DianHei-DEJ', 'IdeaFonts-DianHei';
    font-weight: normal;
    color: #C5C5CA;
    line-height: 0.85rem;
}

input[data-font='en']::placeholder {
    font-size: 0.48rem;
    font-family: Helvetica;
    color: #C5C5CA;
    line-height: 0.75rem;
}
</style>